package cn.edu.nks.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.log4j.Logger;


/**
 * md5加密算法
 * @author wangbs
 *
 */
public class MD5Utile {
	private static Logger logger = Logger.getLogger(MD5Utile.class);
	
	public static String getMD5(String string){
		MessageDigest md = null;
		try {
			md = MessageDigest.getInstance("MD5");
			md.update(string.getBytes());
		} catch (NoSuchAlgorithmException e) {
			logger.warn(String.format("get md5 error %s",e));
		}
		return new BigInteger(1,md.digest()).toString(16);
	}
	
}
